/*
** 3094.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Fri Oct  3 16:31:20 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "3094.h" */
#include <stdio.h>

int main()
{
     int sum, pos;
     
     char c;

     pos = 1;
     sum = 0;
     while((c = getchar()) != '#'){
	  if (c == '\n'){
	       printf("%d\n", sum);
	       pos = 1;
	       sum = 0;
	       continue;
	  }
	  if (c == ' '){
	       pos++;
	       continue;
	  }
	  else
	       sum += pos++ * (c - 'A' + 1);
     }
     return 0;
}

	       
